import { Component, OnInit, AfterViewInit } from "@angular/core";
import { HttpServcie } from "../../../service/http.service";
import { Router } from "@angular/router";
import {
  NzNotificationService,
  NzModalService,
  UploadFile,
  NzModalSubject
} from "ng-zorro-antd";
import { Observable } from "rxjs/Observable";
import { Config } from "../../../service/config";
import {isNull} from "util";

@Component({
  selector: "main-page",
  templateUrl: "main.html",
  styleUrls: ["main.scss"]
})
export class MainPage implements OnInit, AfterViewInit {
  constructor(
    private httpServcie: HttpServcie,
    private router: Router,
    private _notification: NzNotificationService,
    private modalService: NzModalService
  ) {}
  config = Config;
  tab1opend: any;
  tab2opend: any;
  tab3opend: any;
  tab4opend: any;
  tab5opend: any;
  isVisible: boolean = false;
  userVisible: boolean = false;
  partyVisible: boolean = false;
  partyContractVisible: boolean = false;
  elevatorVisible: boolean = false;
  noticlist = [];
  infolist = [];
  elevatorTotal;
  string;
  sysUser: any;
  partyId: any;
  numlist = [];
  elevatorTypeData = [];
  showNI = false;
  usedPartyNum: any;
  maintPartyNum: any;
  feebbackRio: any;
  option1 = {};
  option2 = {};
  option4 = {};
  option5 = {};
  jianguanll = [];
  rescueNum: any;
  drillNum: any;
  checkOrgCount: any;
  repairRio: any;
  czryNumTotal: any;
  maintInRio: any;

  elevatorCount: any;
  emergencyRescueCount: any;
  maintNum: any;
  repairInfoCount: any;
  resoueDrilCount: any;
  appraisalCount: any;

  halfMonData = [];
  quarterData = [];
  halfYearData = [];
  yearData = [];

  showUsedCount = false;
  showMaintCount = false;
  upLoadParam: Object = {};

  inContent: any;
  currentModal: NzModalSubject;
  bannerList: Array<any> = [];
  banners:any = [];

  nzSpinning1: boolean = false;
  ngOnInit() {
    if (window.localStorage.getItem("user")) {
      this.sysUser = JSON.parse(window.localStorage.getItem("user"));
    } else {
      this.router.navigateByUrl("/login");
    }

    this.httpServcie
      .advertiseQuery({ discription: "电脑端" })
      .subscribe(data => {
        if (data.status == 200) {
          if (data.data && data.data.list && data.data.list.length > 0) {
            this.bannerList = data.data.list;
          }else{
            // 当没有数据时，获取默认图片
            let photo:any=["assets/images/banner1.jpg","assets/images/banner2.jpg","assets/images/banner3.jpg"];
            for(var i=0;i<3;i++){
              this.banners.push({url:photo[i]});
            }
          }
        } else if (data.status == 401) {
          this.router.navigateByUrl("/login");
        }
      });
    this.partyId = this.sysUser.partyId;
    this.upLoadParam["partyId"] = this.partyId;
    if (
      this.sysUser.partyType == 1 ||
      this.sysUser.partyType == 2 ||
      this.sysUser.partyType == 3
    ) {
      this.showNI = true;
      if (this.sysUser.userState==1) {
        //消息通知
        this.queryNotice();
      }
      //资讯
      this.queryInfo();
    } else {
      this.showNI = false;
    }

    if (this.sysUser.partyType == 2 && this.sysUser.userState==1) {
      this.showUsedCount = true;
      this.countUsedNum();
    }
    if (this.sysUser.partyType == 1 && this.sysUser.userState==1) {
      this.showMaintCount = true;
      this.countMaintNum();
      this.findTodayMaint();
    }

    /*let screenW=document.body.clientWidth;
    let ratio=screenW/1766;
    let img=document.getElementById("topImg");*/
    /*img.style.height=ratio*635+"px";*/
    /*window.onresize= function () {
      screenW = document.body.clientWidth;
      ratio = screenW / 1766;
      img.style.height = ratio * 635 + "px";
    }*/
  }

  //页面初始化之后
  ngAfterViewInit() {
    //检查机构信息是否完善
    if (this.sysUser.type == "party") {
      this.httpServcie
        .checkParytIdMessage(this.sysUser.partyId)
        .subscribe(data => {
          if (data.status == "200") {
            //判断哪些信息没有完善 用户
            if (data.data.user) {
              this.isVisible = true;
              this.userVisible = true;
            }
            //单位
            if (data.data.party) {
              // type==2 代表分局
              if (data.data.type == '2') {
                this.isVisible = false;
                this.partyVisible = false;
              } else {
                this.isVisible = true;
                this.partyVisible = true;
              }
            }

            //合同
            if (data.data.partyContract && this.sysUser.partyType == 2) {
              this.isVisible = false;
              this.partyContractVisible = false;
            }
            //电梯台账
            if (data.data.elevator) {
              this.isVisible = true;
              this.elevatorVisible = true;
            }
          }
        });
    }
  }

  handleOk(event) {
    this.isVisible = false;
  }
  findTodayMaint() {
    let param = {
      id: this.sysUser.partyId
    };
    this.httpServcie.findTodayMaint(param).subscribe(data => {
      if (data.status == 200) {
        if (data.data && data.data.length > 0) {
          data.data.forEach(maint => {
            if (maint.type == 1) {
              this.halfMonData.push(maint);
            }
            if (maint.type == 2) {
              this.quarterData.push(maint);
            }
            if (maint.type == 3) {
              this.halfYearData.push(maint);
            }
            if (maint.type == 4) {
              this.yearData.push(maint);
            }
          });
        }
      } else if (data.status === 401) {
        this.router.navigateByUrl("/login");
        return;
      } else {
        // 异常
        this._notification.create("error", "错误提示", data.message);
      }
    });
  }

  countUsedNum() {
    let param = {
      id: this.sysUser.partyId
    };
    this.httpServcie.countUsedNum(param).subscribe(data => {
      if (data.status == 200) {
        this.elevatorCount = data.data[0].elevatorCount;
        this.emergencyRescueCount = data.data[0].emergencyRescueCount;
        this.maintNum = data.data[0].maintNum;
        this.repairInfoCount = data.data[0].repairInfoCount;
        this.resoueDrilCount = data.data[0].resoueDrilCount;
        this.appraisalCount = data.data[0].appraisalCount;
      }
    });
  }

  countMaintNum() {
    let param = {
      id: this.sysUser.partyId
    };
    this.httpServcie.countMaintNum(param).subscribe(data => {
      if (data.status == 200) {
        this.elevatorCount = data.data[0].elevatorCount;
        this.maintNum = data.data[0].maintNum;
        this.repairInfoCount = data.data[0].repairInfoCount;
      }
    });
  }

  countEleNum() {
    let param = {
      id: this.sysUser.partyId
    };
    this.httpServcie.countEleNum(param).subscribe(
      data => {
        if (data.status === 200) {
          this.numlist = data.data;
          this.numlist.forEach(element => {
            if (element.id == this.sysUser.partyId) {
              this.elevatorTotal = element.total_count;
            }
          });
        } else if (data.status === 401) {
          this.router.navigateByUrl("/login");
          return;
        } else {
          // 异常
          this._notification.create("error", "错误提示", data.message);
        }
      },
      error => {
        console.log(JSON.stringify(error));
      }
    );
  }

  countLifeOlderYoung() {
    let param = {
      id: this.sysUser.partyId
    };
    Observable.forkJoin(
      this.httpServcie.countLifeOlder(param),
      this.httpServcie.countLifeYounger(param)
    ).subscribe(data => {
      let elevatorYearData = [];
      if (data[0].status == 200) {
        elevatorYearData.push({
          value: data[0].data[0].total_count,
          name: "十年以上"
        });
      } else {
        elevatorYearData.push({
          value: 0,
          name: "十年以上"
        });
      }
      if (data[1].status == 200) {
        elevatorYearData.push({
          value: data[1].data[0].total_count,
          name: "十年以下"
        });
      } else {
        elevatorYearData.push({
          value: 0,
          name: "十年以下"
        });
      }

      this.option2 = {
        title: {
          text: "电梯年龄",
          subtext: "",
          x: "center"
        },
        tooltip: {
          trigger: "item",
          formatter: "{a} <br/>{b} : {c} ({d}%)"
        },
        legend: {
          orient: "vertical",
          left: "left",
          data: ["十年以上", "十年以下"]
        },
        series: [
          {
            name: "电梯",
            type: "pie",
            radius: "30%",
            center: ["45%", "50%"],
            data: elevatorYearData,
            itemStyle: {
              emphasis: {
                shadowBlur: 10,
                shadowOffsetX: 0,
                shadowColor: "rgba(0, 0, 0, 0.5)"
              }
            }
          }
        ]
      };
    });
  }

  countEleTypeNum() {
    let param = {
      id: this.sysUser.partyId
    };
    this.httpServcie.countEleTypeNum(param).subscribe(data => {
      let elevatorTypeList = data.data;
      if (elevatorTypeList) {
        elevatorTypeList.forEach(elevatorType => {
          if (
            elevatorType.id == this.sysUser.partyId &&
            elevatorType.elevator_type_id == 1
          ) {
            this.elevatorTypeData.push({
              value: elevatorType.total_count,
              name: "载客电梯"
            });
          }
          if (
            elevatorType.id == this.sysUser.partyId &&
            elevatorType.elevator_type_id == 5
          ) {
            this.elevatorTypeData.push({
              value: elevatorType.total_count,
              name: "载货电梯"
            });
          }
          if (
            elevatorType.id == this.sysUser.partyId &&
            elevatorType.elevator_type_id == 2
          ) {
            this.elevatorTypeData.push({
              value: elevatorType.total_count,
              name: "液压驱动电梯"
            });
          }
          if (
            elevatorType.id == this.sysUser.partyId &&
            elevatorType.elevator_type_id == 3
          ) {
            this.elevatorTypeData.push({
              value: elevatorType.total_count,
              name: "杂物电梯"
            });
          }
          if (
            elevatorType.id == this.sysUser.partyId &&
            elevatorType.elevator_type_id == 4
          ) {
            this.elevatorTypeData.push({
              value: elevatorType.total_count,
              name: "自动扶梯"
            });
          }
          if (
            elevatorType.id == this.sysUser.partyId &&
            elevatorType.elevator_type_id == 6
          ) {
            this.elevatorTypeData.push({
              value: elevatorType.total_count,
              name: "自动人行道"
            });
          }
        });
      }

      this.option1 = {
        title: {
          text: "电梯类型",
          subtext: "",
          x: "center"
        },
        tooltip: {
          trigger: "item",
          formatter: "{a} <br/>{b} : {c} ({d}%)"
        },
        legend: {
          orient: "vertical",
          left: "left",
          data: ["曳引驱动电梯", "自动扶梯/人行道", "液压驱动电梯", "杂物电梯"]
        },
        series: [
          {
            name: "电梯",
            type: "pie",
            radius: "30%",
            center: ["45%", "50%"],
            data: this.elevatorTypeData,
            itemStyle: {
              emphasis: {
                shadowBlur: 10,
                shadowOffsetX: 0,
                shadowColor: "rgba(0, 0, 0, 0.5)"
              }
            }
          }
        ]
      };
    });
  }

  queryNotice() {
    let param = {
      isRead: 0,
      pageSize: 5,
      currentPage: 1,
      currentUserId: this.sysUser.id
    };
    this.httpServcie.getNoticeList(param).subscribe(
      data => {
        if (data.status === 200) {
          this.noticlist = data.data.list;
        } else if (data.status === 401) {
          this.router.navigateByUrl("/login");
          return;
        } else {
          // 异常
          this._notification.create("error", "错误提示", data.message);
        }
      },
      error => {
        console.log(JSON.stringify(error));
      }
    );
  }

  toNoticePage() {
    this.router.navigateByUrl("/home/notice");
  }

  toInformationPage() {
    this.router.navigateByUrl("/home/information");
  }

  queryInfo() {
    let param = {};
    if (this.sysUser.userState==1) {
      param = {
        pageSize: 5,
        currentPage: 1,
        createPartyId: JSON.parse(window.localStorage["user"]).partyId,
        parentId: JSON.parse(window.localStorage["user"]).partyParentId
      };
    } else {
      param = {
        pageSize: 5,
        currentPage: 1,
        createPartyId: JSON.parse(window.localStorage["user"]).partyId,
        parentId: JSON.parse(window.localStorage["user"]).partyParentId,
        userId: JSON.parse(window.localStorage["user"]).id
      };
    }
    this.httpServcie.getInformationList(param).subscribe(
      data => {
        if (data.status === 200) {
          this.infolist = data.data.list;
        } else if (data.status === 401) {
          this.router.navigateByUrl("/login");
          return;
        } else {
          // 异常
          this._notification.create("error", "错误提示", data.message);
        }
      },
      error => {
        console.log(JSON.stringify(error));
      }
    );
  }

  countUseCompany() {
    let param = {
      id: this.sysUser.partyId
    };
    this.httpServcie.countUseCompany(param).subscribe(data => {
      if (data.status == 200) {
        this.usedPartyNum = data.data[0].total_count;
      }
    });
  }

  countMaintCompany() {
    let param = {
      id: this.sysUser.partyId
    };
    this.httpServcie.countMaintCompany(param).subscribe(data => {
      if (data.status == 200) {
        this.maintPartyNum = data.data[0].total_count;
      }
    });
  }
  countCompanyQuali() {
    let param = {
      id: this.sysUser.partyId
    };
    this.httpServcie.countCompanyQuali(param).subscribe(data => {
      if (data.status == 200) {
        let jianguanList = data.data;
        jianguanList.forEach(jianguan => {
          if (jianguan.party_type == 4) {
            this.jianguanll.push(jianguan);
          }
        });
      }
    });
  }

  countFeedbackRio() {
    let param = {
      id: this.sysUser.partyId
    };
    this.httpServcie.countFeedbackRio(param).subscribe(data => {
      if (data.status == 200) {
        let feedBackList = data.data;
        feedBackList.forEach(feedback => {
          if (feedback.id == this.sysUser.partyId) {
            this.feebbackRio = feedback.feedback_rio * 100 + "%";
          }
        });
      }
    });
  }

  countStarCompany() {
    let param = {
      id: this.sysUser.partyId
    };
    this.httpServcie.countStarCompany(param).subscribe(data => {
      let startNumMaintList: Array<Object> = data.data;
      let starList = [];
      if (startNumMaintList) {
        for (let i = 0; i < startNumMaintList.length; i++) {
          if (i == 0) {
            startNumMaintList.pop();
          }
        }
        let star5 = 0;
        let star4 = 0;
        let star3 = 0;
        let star2 = 0;
        let star1 = 0;
        let star0 = 0;
        startNumMaintList.forEach(satrtNumMaint => {
          if (satrtNumMaint["start_num"] == 5) {
            star5++;
          }
          if (satrtNumMaint["start_num"] == 4) {
            star4++;
          }
          if (satrtNumMaint["start_num"] == 3) {
            star3++;
          }
          if (satrtNumMaint["start_num"] == 2) {
            star2++;
          }
          if (satrtNumMaint["start_num"] == 1) {
            star1++;
          }
          if (!satrtNumMaint["start_num"] || satrtNumMaint["start_num"] == 0) {
            star0++;
          }
        });
        starList.push({
          name: "五星",
          value: star5
        });
        starList.push({
          name: "四星",
          value: star4
        });
        starList.push({
          name: "三星",
          value: star3
        });
        starList.push({
          name: "二星",
          value: star2
        });
        starList.push({
          name: "一星",
          value: star1
        });
        starList.push({
          name: "零星",
          value: star0
        });
      }

      this.option4 = {
        title: {
          text: "维保星级",
          subtext: "",
          x: "center"
        },
        tooltip: {
          trigger: "item",
          formatter: "{a} <br/>{b} : {c} ({d}%)"
        },
        legend: {
          orient: "vertical",
          left: "left",
          data: ["五星", "四星", "三星", "二星", "一星", "零星"]
        },
        series: [
          {
            name: "星级",
            type: "pie",
            radius: "30%",
            center: ["45%", "50%"],
            data: starList,
            itemStyle: {
              emphasis: {
                shadowBlur: 10,
                shadowOffsetX: 0,
                shadowColor: "rgba(0, 0, 0, 0.5)"
              }
            }
          }
        ]
      };
    });
  }

  countTechmanCompany() {
    let param = {
      id: this.sysUser.partyId
    };
    this.httpServcie.countTechmanCompany(param).subscribe(data => {
      if (data.status == 200) {
        let countTechmanList = data.data;
        countTechmanList.forEach(countTechman => {
          if (countTechman.id == this.sysUser.partyId) {
            this.czryNumTotal = countTechman.czry_num;
          }
        });
      }
    });
  }

  countRescue() {
    let param = {
      id: this.sysUser.partyId
    };
    this.httpServcie.countRescue(param).subscribe(data => {
      if (data.status == 200) {
        let rescueList = data.data;
        rescueList.forEach(rescue => {
          if (rescue.id == this.sysUser.partyId) {
            this.rescueNum = rescue.rescue_count;
          }
        });
      }
    });
  }

  countRescueDrill() {
    let param = {
      id: this.sysUser.partyId
    };
    this.httpServcie.countRescueDrill(param).subscribe(data => {
      if (data.status == 200) {
        let rescueDrillList = data.data;
        rescueDrillList.forEach(rescueDrill => {
          if (rescueDrill.id == this.sysUser.partyId) {
            this.drillNum = rescueDrill.drill_count;
          }
        });
      }
    });
  }

  countCheckOrgNum() {
    let param = {
      id: this.sysUser.partyId
    };
    this.httpServcie.countCheckOrgNum(param).subscribe(data => {
      if (data.status == 200) {
        let ppList = data.data;
        ppList.forEach(pp => {
          if (pp.id == this.sysUser.partyId) {
            this.checkOrgCount = pp.check_org_num;
          }
        });
      }
    });
  }

  countRepair() {
    let param = {
      id: this.sysUser.partyId
    };
    this.httpServcie.countRepair(param).subscribe(data => {
      if (data.status == 200) {
        let repList = data.data;
        repList.forEach(rep => {
          if (rep.id == this.sysUser.partyId) {
            this.repairRio = rep.repaired_rio * 100 + "%";
          }
        });
      }
    });
  }

  countMaint() {
    let param = {
      id: this.sysUser.partyId
    };
    this.httpServcie.countMaint(param).subscribe(data => {
      if (data.status == 200) {
        let maintIntimeList = data.data.maintInTime;
        maintIntimeList.forEach(maintInTime => {
          if (maintInTime.id == this.sysUser.partyId) {
            this.maintInRio = maintInTime.maint_rio * 100 + "%";
          }
        });

        let maintTimeList = data.data.maintTime;

        let dataList = [0, 0, 0, 0];

        maintTimeList.forEach(maintTime => {
          if (maintTime.id == this.sysUser.partyId) {
            if (maintTime.type == 1) {
              dataList[0] = maintTime.maint_used_time;
            }
            if (maintTime.type == 2) {
              dataList[1] = maintTime.maint_used_time;
            }
            if (maintTime.type == 3) {
              dataList[2] = maintTime.maint_used_time;
            }
            if (maintTime.type == 4) {
              dataList[3] = maintTime.maint_used_time;
            }
          }
        });

        this.option5 = {
          color: ["#3398DB"],
          tooltip: {
            trigger: "axis",
            axisPointer: {
              // 坐标轴指示器，坐标轴触发有效
              type: "shadow" // 默认为直线，可选为：'line' | 'shadow'
            }
          },
          grid: {
            left: "3%",
            right: "4%",
            bottom: "3%",
            containLabel: true
          },
          xAxis: [
            {
              type: "category",
              data: ["半月保", "季度保", "半年保", "年保"],
              axisTick: {
                alignWithLabel: true
              }
            }
          ],
          yAxis: [
            {
              type: "value"
            }
          ],
          series: [
            {
              name: "平均时间",
              type: "bar",
              barWidth: "15",
              data: dataList //[10, 52, 200, 334, 390, 330, 220]
            }
          ]
        };
      }
    });
  }

  selectChanged(event) {
    //只加载一次处理 + 懒加载处理
    if (this.tab1opend != 1 && event == 1) {
      this.tab1opend = event;
    }
    if (this.tab2opend != 2 && event == 2) {
      this.tab2opend = event;
    }
    if (this.tab3opend != 3 && event == 3) {
      this.tab3opend = event;
    }
    if (this.tab4opend != 4 && event == 4) {
      this.tab4opend = event;
    }
  }

  beforeUpload = (file: File) => {
    this.nzSpinning1 = true;
    return true;
  };

  //上传回调
  uploadChage(info: { file: UploadFile }, param) {
    if (info.file.status === "uploading") {
      return;
    }
    this.nzSpinning1 = false;
    if (info.file.status === "done") {
      //设置为接口的查询不然反显有时候没用
      if (info.file.response.status != "200") {
        this._notification.create(
          "error",
          "错误提示",
          info.file.response.message
        );
      } else {
        switch (param) {
          case "user":
            this.userVisible = false;
          case "party":
            this.partyVisible = false;
          case "elevator":
            this.elevatorVisible = false;
        }
        this.isVisible = this.checkIsVisible();
        this._notification.create("success", "提示", "导入成功");
      }
      // Get this url from response in real world.
    }
  }

  //判断模特框是否显示
  checkIsVisible() {
    if (
      this.userVisible == true ||
      this.partyVisible == true ||
      this.partyContractVisible == true ||
      this.elevatorVisible == true
    ) {
      return true;
    }
    return false;
  }

  showInfo(titless, contentss, footerss, data) {
    this.inContent = data;
    this.currentModal = this.modalService.open({
      title: titless,
      content: contentss,
      footer: footerss,
      maskClosable: false,
      width: 900,
      style: {
        top: "20px"
      },
      onOk() {
        console.log("Click ok");
      }
    });
  }

  export(data) {
    let param = {
      halfMonId: data.id,
      elevatorNum: data.elevatorNum,
      elevatorType: data.elevatorTypeId
    };
    this.httpServcie.exportMaint(param).subscribe(data => {
      if (data.status == 200) {
        this.download(data.data.fileUrl, data.data.fileName);
        this._notification.create("success", "提示", "导出成功");
      } else {
        this._notification.create("error", "提示", "导出失败");
      }
    });
  }
  download(url, name) {
    let link = document.createElement("a");
    let body = document.querySelector("body");

    this.getBlob(this.config.IP + this.config.API.getUpload + url).then(
      blob => {
        link.href = window.URL.createObjectURL(blob);
        link.download = name;
        // fix Firefox
        link.style.display = "none";
        body.appendChild(link);
        link.click();
        body.removeChild(link);
        window.URL.revokeObjectURL(link.href);
      }
    );
  }
  getBlob(url) {
    return new Promise(resolve => {
      const xhr = new XMLHttpRequest();
      xhr.open("GET", url, true);
      xhr.responseType = "blob";
      xhr.onload = () => {
        if (xhr.status === 200) {
          resolve(xhr.response);
        }
      };
      xhr.send();
    });
  }

  /**
   * 获取广告展示类型 1、纯图片展示  2、跳转外部链接 3、跳转到资讯详情 4、跳内部页面，5、下载安卓app 6、下载ios app
   * @param event 图片对象
   */
  toLinkAddress(event){
    if((event.operateType == 2 || event.operateType == 4) && !isNull(event.linkUrl)){
      window.open(event.linkUrl);
    }
    if(event.operateType == 3){
      this.getInformationUrl(event);
    }
  }

  /**
   * 获取资讯的文件地址
   */
  getInformationUrl(event){
    this.httpServcie.getInformationById({id:event.infoId}).subscribe(
      data => {
        if (data.status === 200) {
          if("" != data.data.fileUrls){
            this.openDocs(data.data.fileUrls);
          }
        }
      },
      error => {
        console.log(JSON.stringify(error));
      }
    );
  }

  /**
   * 获取咨询的地址
   */
  openDocs(url) {
    let list: Array<string> = [
      "doc",
      "dot",
      "docx",
      "dotx",
      "docm",
      "dotm",
      "xls",
      "xlt",
      "xla",
      "xlsx",
      "xltx",
      "xlsm",
      "xltm",
      "xlam",
      "xlsb",
      "ppt",
      "pot",
      "pps",
      "ppa",
      "pptx",
      "potx",
      "ppsx",
      "ppam",
      "pptm",
      "potm",
      "ppsm"
    ];
    let lookUrl = "";
    let tt = url.split(".");
    let houzui = null;
    if (tt.length > 1) {
      houzui = tt[tt.length - 1];
    }
    if (houzui) {
      if (list.indexOf(houzui) >= 0) {
        lookUrl = Config.OFFICE_URL + Config.PREVIEW_URL + url;
      } else {
        lookUrl = Config.PREVIEW_URL + url;
      }
    } else {
      lookUrl = Config.PREVIEW_URL + url;
    }
    // window.open(lookUrl);
    let openBean = window.open() ;
    openBean.location.replace(lookUrl);

  }
}
